<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
</head>
<body>

<h1>注册</h1>
<form class="layui-form" action="">
    {% csrf_token %}
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-inline">
            <input type="text" name="account" required lay-verify="required" placeholder="请输入标题" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="*">login</button>
            <button class="layui-btn" lay-submit lay-filter="**">register</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="https://www.layuicdn.com/layui/layui.all.js"></script>
<script>
    var form = layui.form;
    var layer = layui.layer;
    var $ = layui.jquery;
    //监听提交
    form.on('submit(*)', function (data) {
        $.post({
            url: "{% url 'auth:login' %}",
            data: data.field,
            success: function (res) {
                console.log(res)
            }
        })
        return false;
    });
    form.on('submit(**)', function (data) {
        $.post({
            url: "{% url 'auth:register' %}",
            data: data.field,
            success: function (res) {
                console.log(res)
            }
        })
        return false;
    });
</script>
</body>
</html>